Performance counter for adding variable work increment value that is dependent upon clock frequency

ABSTRACT

A performance counter accumulates a value by periodically adding a variable increment value representing the amount of work performed. The increment value can be varied in dependence upon the processor clock frequency and may be adjusted under hardware and/or software control.

The U.S. Government has a paid-up license in this invention and theright in limited circumstances to require the patent owner to licenseothers on reasonable terms as provided for by the terms ofF33615-00-C-1678 awarded by Defense Advanced Research Projects Agency.

BACKGROUND OF THE INVENTION

1. Field of the Invention

This invention relates to data processing systems. More particularly,this invention relates to performance counters in data processingsystems.

2. Description of the Prior Art

In order to monitor and/or control the performance level within a dataprocessing system it is desirable to have a performance counter. It isknown to provide performance counters that count the number ofprocessing cycles executed by a processor. Such performance counters donot readily combine with information concerning real time as the countrate will vary with the processing clock speed selected without a readyindication of whether a desired amount of processing has been donewithin a desired amount of time.

It is also known to provide real time clocks which operate by steadilyincrementing a count value under control of a fixed clock frequency tokeep track of the passage of time. Such real time clocks do not providean indication of the number of processing cycles that may or may nothave been performed in a given period of time dependent upon theparticular clock frequency for the processor being used at that time.

It would be desirable to provide a performance counter that was able totake account of different processing clock signals that may be selectedat different times and yet provide real time based performanceinformation.

SUMMARY OF THE INVENTION

Viewed from one aspect the present invention provides apparatus forprocessing data, said apparatus being operable to perform processingwork at a variable rate of work and comprising:

a performance counter operable to add a work increment value to anaccumulated work done value to accumulate a work done value indicativeof an amount of processing work performed by said apparatus; wherein

said work increment value is variable so as to represent said variablerate of work.

The invention provides a performance calculator which steadilyaccumulates a work done value by adding a variable work increment valuerepresenting the amount of processing work done since the last workincrement value was added. Thus, by varying the work increment value thesystem can take account of the different amount of work that may beperformed in a unit of time depending upon the particular status of thesystem, such as the clock speed being used, the memory performancecharacteristics at that clock speed and the like. In addition, theadding of the increment value can be performed at regular intervalsthereby providing a real time basis for the performance measurement andthe measurement of processing work actually done.

Preferred embodiments of the invention operate in systems in which theprocessing clock frequency can vary and in such systems the incrementvalue is varied in dependence upon the processing clock frequency(possibly with a non-linear dependence between the processing clockfrequency and the increment value).

Preferred embodiments provide a power supply that operates to supply aplurality of different voltage levels each corresponding to a respectiveperformance level that can be tracked by the performance counter.

More particularly, in preferred embodiments the voltage level can alterthe processor clock frequency and the maximum processor clock frequencyin turn alter the increment value being used in a manner such that theamount of work done (processing cycles clocked at a first approximation)can be tracked.

The increment value may be controlled by hardware, such as a clocksignal selector, a voltage selector or the like and/or may beprogrammably controlled by software. This control of the increment valueprovides for a low-overhead way of adjusting the increment value toaccurately reflect the current performance level by using a hardwareadjustment mechanism and yet also allows software control of theincrement value to be made when desired in dependence upon possibly moresophisticated algorithms that are better performed in software. Themodification made can be of a read-modify-write form such that theadjustments made by other processes will not be simply overwritten.

The increment value may be provided in the form of a configurationregister which may be written both under software and hardware controlor possibly in the form of a direct memory map storage location whichcan similarly be written under hardware and/or software control.

Viewed from another aspect the present invention provides a method ofmeasuring processing work performed by an apparatus for processing dataat a variable rate of work, said method comprising the steps of:

adding a work increment value to an accumulated work done value with aperformance counter to accumulate a work done value indicative of anamount of processing work performed by said apparatus; and

varying said work increment value so as to represent said variable rateof work.

The above, and other objects, features and advantages of this inventionwill be apparent from the following detailed description of illustrativeembodiments which is to be read in connection with the accompanyingdrawings.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 schematically illustrates how a power management system accordingto the present technique may be implemented in a data processing system;

FIG. 2 schematically illustrates three hierarchical layers of theperformance setting algorithm according to the present technique.

FIG. 3 illustrates the strategy for setting the processor performancelevel during an interactive episode;

FIG. 4 schematically illustrates execution of a workload on theprocessor and calculation of the utilisation-history window for a taskA;

FIG. 5 schematically illustrates an implementation of the three-layerhierarchical performance policy stack of FIG. 2;

FIG. 6 schematically illustrates a work-tracking counter 600 accordingto the present technique;

FIG. 7 schematically illustrates an apparatus that is capable ofproviding a number of different fixed performance-levels in dependenceupon workload characteristics;

FIG. 8 is a table that details simulation measurement results for a‘plaympeg’ video player playing a variety of MPEG videos;

FIG. 9 is a table that lists processor performance levels statisticsduring the runs of each workload;

FIG. 10 comprises two graphs of results for playback of two differentMPEG movies entitled ‘Legendary’ (FIG. 10A) and ‘Danse de Cable’ (FIG.10B);

FIGS. 11A, B and C schematically illustrate the characteristics of twodifferent performance-setting policies;

FIGS. 12A, B and C schematically illustrate simulation results fordifferent performance-setting algorithms tested on interactiveworkloads;

FIG. 13 schematically illustrates statistics gathered using a time-skewcorrection technique.

DESCRIPTION OF THE PREFERRED EMBODIMENTS

FIG. 1 schematically illustrates how the power management system may beimplemented in a data processing system. The data processing systemcomprises a kernel 100 having standard kernel functional modulesincluding a system calls module 112, a scheduler 114 and a conventionalpower manager 116. An intelligent energy manager system 120 isimplemented in the kernel and comprises a policy co-ordinator 122, aperformance setting control module 124 and an event-tracing module 126.A user processes layer 130 comprises a system calls module 132, a taskmanagement module 134 and application specific data 136. The userprocesses layer 130 supplies information to the kernel 100 via anapplication-monitoring module 140.

The kernel 100 is the core that provides basic services for other partsof the operating system. The kernel can be contrasted with the shell,which is the outermost part of the operating system that interacts withuser commands. The code of the kernel is executed with complete accessprivileges for physical resources, such as memory, on its host system.The services of the kernel are requested by other parts of the system orby an application program through a set of program interfaces known assystem call. Both the user process layer and the kernel have systemcalls modules 112, 132. The scheduler 114 determines which programsshare the kernel's processing time and in what order. A supervisor (notshown) within the kernel gives use of the processor to each process atthe scheduled time. The conventional power manager 116 manages thesupply voltage by switching the processor between a power-conservingsleep mode and a standard awake-mode in dependence upon the level ofprocessor utilisation.

The intelligent energy manager 120 is responsible for calculating andsetting processor performance targets. Rather than relying only on sleepmode for power conservation, the intelligent energy manager 120 allowsthe central processing unit (CPU) operating voltage and the processorclock frequency to be reduced without causing the application softwareto miss process (i.e. task) deadlines. When the CPU is running at fullcapacity many processing tasks will be completed in advance of theirdeadlines whereupon the processor will idle until the next scheduledtask is begun. An example of a task deadline for a task that producesdata is the point at which the produced data is required by anothertask. The deadline for an interactive task would be the perceptionthreshold of the user (50-100 ms). Going at full performance and thenidling is less energy-efficient than completing the task more slowly sothat the deadline is met more exactly. When the processor frequency isreduced, the voltage may be scaled down in order to achieve energysavings. For processors implemented in complementary metal-oxidesemiconductor (CMOS) technology the energy used for a given workload isproportional to the voltage squared. The policy co-ordinator managesmultiple performance-setting algorithms, each being appropriate todifferent run-time situations. The most suitable performance-settingalgorithm to a given condition is selected at run-time. The performancesetting control module 124 receives the results of eachperformance-setting algorithm and repeatedly calculates a targetprocessor performance by prioritising these results. The event tracingmodule 126 monitors system events both in the kernel 110 and in the userprocess layer 130 and feeds the information gathered to the performancesetting control module 124 and the policy co-ordinator 122.

In the user processes layer, processing work is monitored via: systemcall events 132; processing task events 134 including task switching,task creation and task exit events; and via application-specific data.The intelligent energy manager 120 is implemented as a set of kernelmodules and patches that hook into the standard kernel functionalmodules and serve to control the speed and voltage levels of theprocessor. The way in which the intelligent energy manager 120 isimplemented makes it relatively autonomous from other modules in thekernel 100. This has the advantage of making the performance settingcontrol mechanism less intrusive to the host operating system.Implementation in the kernel also means that user application programsneed not be modified. Accordingly, the intelligent energy manager 120co-exists with the system calls module 112, the scheduler 114 and theconventional power manager 116 of the kernel, although it may requirecertain hooks within these sub-systems. The intelligent energy manager120 is used to derive task deadlines and task classification information(e.g. whether the task associated with an interactive application) fromthe OS kernel by examining the communication patterns between theexecuting tasks. It also serves to monitor which system calls areaccessed by each task and how data flows between the communicationstructures in the kernel.

FIG. 2 schematically illustrates three hierarchical layers of theperformance setting algorithm according to the present technique. Itshould be noted that on a given processor, the frequency/voltage settingoptions are typically discrete rather than continuous. Accordingly thetarget processor performance level must be chosen from a fixed set ofpredetermined values. Whereas known techniques of calculating a targetprocessor performance level involve use of a single performance-settingalgorithm, the present technique utilises multiple algorithms each ofwhich have different characteristics appropriate to different run-timesituations. The most applicable algorithm to a given processingsituation is selected at run-time. The policy co-ordinator module 122co-ordinates the performance setting algorithms and by connecting tohooks in the standard kernel 110, provides shared functionality to themultiple performance setting algorithms. The results of the multipleperformance-setting algorithms are collated and analysed to determine aglobal estimate for a target processor performance level. The variousalgorithms are organised into a decision hierarchy (or algorithm stack)in which the performance level indicators output by algorithms at upper(more dominant) levels of the hierarchy have the right to override theperformance level indicators output by algorithms at lower (lessdominant) levels of the hierarchy. The example embodiment of FIG. 2 hasthree hierarchical levels. At the uppermost level of the hierarchy thereis an interactive application performance indicator 210, at the middlelevel there is an application-specific performance indicator 220 and atthe lowermost level of the hierarchy there is a task-based processorutilisation performance indicator 230.

The interactive application performance indicator 210 calculation isperformed by an algorithm based on that described in Flautner et. Al.“Automatic Performance-setting for Dynamic Voltage Scaling”, Proceedingsof the International Conference on Mobile Computing and Networking, July2001. The interactive application performance-level prediction algorithmseeks to provide guarantees good interactive performance by finding theperiods of execution that directly impact the user experience andensuring that these episodes complete without undue delay. The algorithmuses a relatively simple technique for automatically isolatinginteractive episodes. This technique relies on monitoring communicationfrom the X server, which is the GUI controller, and tracking theexecution of the tasks that get triggered as a result.

The beginning of an interactive episode (which typically comprises amultiplicity of tasks) is initiated by the user and is signified by aGUI event, such as pressing a mouse button or a key on the keyboard. Asa result this event, the GUI controller (X server in this case)dispatches a message to the task that is responsible for handling theevent. By monitoring the appropriate system calls (various versions ofread, write, and select), the intelligent energy manager 120 canautomatically detect the beginning of an interactive episode. When theepisode starts, both the GUI controller and the task that is thereceiver of the message are marked as being in an interactive episode.If tasks of an interactive episode communicate with unmarked tasks, thenthe as yet unmarked tasks are also marked. During this process, theintelligent energy manager 120 keeps track of how many of the markedtasks have been pre-empted. The end of the episode is reached when thenumber of pre-empted tasks is zero, indicating that all tasks have runto completion.

FIG. 3 illustrates the strategy for setting the processor performancelevel during an interactive episode. The duration of an interactiveepisode is known to vary by several orders of magnitude (from around10⁻⁴s up to around 1 second). However a transition-start latency or‘skip threshold’ of 5 milliseconds is set to filter out the shortestinteractive episodes thereby reducing the number of requestedperformance-level transitions. The sub-millisecond interactive episodesare typically the results of echoing key presses to the window or movingthe mouse across the screen and redrawing small rectangles. The skipthreshold is set at 5 milliseconds since this allows short episodes tobe filtered out of the performance indicator predictions withoutadversely impacting the worst case.

If the interactive episode duration exceeds the skip threshold, then theassociated performance-level value is included in the overallinteractive performance-level prediction. The performance factor for thenext interactive episode is given by a weighted exponentially decayingaverage of calculated performance factors for all past interactiveepisodes. Note that according to the present technique the interactiveapplication performance setting algorithm uses a single globalprediction for the necessary performance level for an interactiveepisode in the system. [This differs from the technique described in theabove-mentioned publication, according to which a per-taskperformance-level prediction was used depending on which task initiatedthe episode.]

To bound the worst-case impact of an erroneous performance-levelprediction on the user experience, if the interactive episode does notfinish before reaching a so-called ‘panic threshold’, then theperformance-level prediction of the top hierarchical layer is specifiedto be the maximum performance level. Since this is a top-levelprediction it will be enforced by the system. At the end of theoffending interactive episode, the interactive algorithm computes whatthe correct performance-setting for the episode should have been andthis corrected value is incorporated into the exponentially decayingaverage so that it will influence future predictions. An additionaloptimisation is performed such that that if the panic threshold was infact reached during an interactive episode, the moving average isre-scaled so that the corrected performance level is incorporated in theexponentially decaying average with a higher weight (k=1 is used insteadof k=3). The performance prediction is computed for all episodes thatare longer than the skip threshold.

Interactive episode ‘deadlines’ are used to obtain a performance-levelindicator for each identified interactive episode. The deadline is thelatest time by which a task must be completed to avoid adverselyimpacting performance. The performance level indicator for interactiveepisodes is calculated in dependence upon the human perception thresholdassociated with the particular interactive event. For example, it isknown that a rate of 20 to 30 frames per second is fast enough for theuser to perceive a series of images as a continuous stream so that theperception threshold could be set to 50 ms for an interactive imagedisplay episode. Although the exact value of the perception threshold isdependent on the user and the type of task being accomplished, a fixedvalue of 50 ms was found to be adequate for the interactive algorithm ofthe hierarchy. The equation below is used for computing the performancerequirements of episodes that are shorter than the perception threshold.

${Perf} = \frac{{Work}_{fse}}{{Perception}\mspace{20mu}{Threshold}}$

where the full-speed equivalent work Work_(fse) is measured from thebeginning of the interactive episode.

The application-specific performance indicator 220 of the middlehierarchical layer is obtained by collating information output by acategory of application programs that are aware of performance levelsetting functionality. These program applications have been adapted tosubmit (via system calls) specific information to the intelligent energymanager 120 about their specific performance requirements. The operatingsystem and application programs can be provided with new API elements tofacilitate this communication regarding performance requirements.

The perspectives-based performance indicator 230 is obtained byimplementing a perspectives based algorithm that estimates futureutilisation of the processor based on the recent utilisation history.This algorithm derives a utilisation estimate for each individual taskand adjusts the size of a the time period over which theutilisation-history is calculated (i.e. the utilisation-history window)on a task by task basis. The perspectives-based algorithm takes accountof all categories of task being performed by the processor whereas theinteractive application algorithm of the uppermost layer takes accountof interactive tasks. Since the interactive application algorithmcalculates a performance-level indicator that aims to guarantee a highquality of interactive performance and it is situated at the uppermostlevel of the hierarchy, the perspectives-based algorithm need not beconstrained to a conservatively short utilisation-history window. Thepossibility of using longer utilisation-history windows at thislowermost hierarchical level allows for improved efficiency since a moreaggressive power reduction strategy can be selected when appropriate. Ifthe utilisation-history window is too short, this can cause theperformance-level predictions to oscillate rapidly between two fixedvalues. It is typically necessary to set a short utilisation historywindow where a single unified algorithm (rather than a hierarchical setof algorithms) is used to set the performance level for all run-timecircumstances. To be able to cope with intermittent processor-intensiveinteractive events, such unified algorithms must keep theutilisation-history window short.

Each of the performance-setting algorithms of the 3-layer stack uses ameasure of processing work-done in a given time interval. In thisembodiment, the work-done measure that is used is the full-speed (of theprocessor) equivalent work Work_(fse) performed in that time interval.This full-speed equivalent work estimate is calculated according to thefollowing formula:

${{Work}_{fse}1} = {1{\sum\limits_{i = 1}^{n}\;{t_{i}p_{i}}}}$

where i is one of n different processor performance levels implementedduring the given time interval; t_(i) is the non-idle time in secondsspent at performance level i; and p_(i) is the processor performancelevel i expressed as a fraction of the peak (full-speed) processorperformance level. This equation is valid on a system in which atime-stamp counter (work counter) measures real time. The work-donewould be calculated differently in alternative embodiments that usecycle counters whose count rate varies according to the currentprocessor frequency. Furthermore, the above equation makes the implicitassumption that the run-time of a workload is inversely proportional tothe processor frequency. This assumption provides a reasonable estimateof work-done. However, primarily due to the non-linearity of bus speedto processor speed ratios during performance scaling, the assumption isnot always accurate. In alternative embodiments the work-donecalculation can be fine-tuned to take account of such factors.

FIG. 4 schematically illustrates execution of a workload on theprocessor and calculation of the utilisation-history window for a taskA. The horizontal axis of FIG. 4 represents time. Task A first startsexecution at time S, whereupon a number of per-task data structures areinitialised. There are four of these data structures corresponding tothe following four pieces of information: (i) the current state of thework counter; (ii) the current (real) time; (iii) the current state ofan idle-time counter; and (iv) a run bit is set to logical level ‘1’indicating that the task has started running. The work-counter, thereal-time counter and the idle-time counters are used to calculate theprocessor utilisation associated with task A and subsequently tocalculate task A's performance requirements. At time PE, task A has notyet run to completion but is pre-empted by another task, task B.Pre-empting will occur when the task scheduler 114 determines thatanother task has higher priority than the task that is currentlyrunning. When task A is pre-empted the run bit is maintained at logicallevel of ‘1’ to indicate that the task still has work to complete. Attime RE, task A resumes execution, having been rescheduled, andcontinues to execute until it has run to completion at time TC whereuponit voluntarily gives up processing time. On completion task A mayinitiate a system call that yields the processor to another task. Oncompletion of task A at time TC the run-bit is reset to logical level‘0’.

After time TC, there is an idle period followed by execution of afurther task C and a subsequent idle period. At time RS, task A beginsexecution for a second time. At time RS, the ‘0’ state of the run-bitassociated with task A indicates that information exists to enablecalculation of task A's performance requirements so that the processortarget performance level can be accordingly set for the imminentre-execution of task A. The utilisation-history window for a given taskis defined to be the period of time from the start of the firstexecution of the given task to the start of the subsequent execution ofthe given task and should include at least one pre-empting event (task Ais pre-empted by task B at point RE in this case) of the given taskwithin the relevant window. Accordingly, in this case theutilisation-history window for task A is defined to be the time periodfrom time S to time RS. The target performance level for task A in thiswindow is calculated as follows:WorkEst_(New)=(k×WorkEst_(Old)+Work_(fse))/(k+1)Deadline_(New)=(k×Deadline_(Old)+(Work_(fse)+Idle))/(k+1)

where k is a weighting factor, Idle is the idle time in seconds in thetime interval from time S to time RS in FIG. 4 and the deadline for taskA is defined to be (Work_(fse)+Idle). In this particular example,performing detection of pre-empting tasks such as task B in FIG. 4guides the algorithm in determining the utilisation-history window foreach task. Processing tasks that are run before the next non-preemptedscheduling of task A are often highly correlated with the execution oftask A. The idle time between time points TC and RS is the “slack” thatcan be taken up by running the processor at a reduced performance level.However, task C is factored into the performance level calculation sinceit diminishes the available slack.

The above equations for WorkEst_(New) and Deadline_(New) each representan exponentially decaying average. Such exponentially decaying averagesallow for more recent estimates to have more influence on the averagethan less recent estimates. The weighting factor k is a parameterassociated with the exponentially decaying average. It was found that avalue of k=3 worked effectively and this small value indicates that eachestimate is a good estimate. By keeping track of the work predictor andthe deadline predictor separately, the performance predictions areweighted according to the length of the utilisation-history window. Thisensures that the performance estimates associated with the larger windowsizes do not dominate the performance prediction. The performance levelindicator Perf_(perspectives-based) for this algorithm is given by theratio of the two exponentially decaying averages:Perf_(perspectives-based)=WorkEst_(New)/Deadline_(New). A separateperformance level value is calculated for each task. According to thestrategy of the present technique, the work estimates WorkEst for agiven task is re-calculated on a workload dependent time-interval ofbetween 50 and 150 milliseconds. However, since WorkEst is calculated ona task by task basis so that each executed task draws on a respectiveappropriate task-based WorkEst value, the WorkEst is actually refinedevery 5 to 10 milliseconds (reflecting task switching events). Thisalgorithm differs from known interval-based algorithms in that itderives an utilisation estimate separately for each task and alsoadjusts the size of the utilisation-history window on a task by taskbasis. Although known unified performance-setting algorithms useexponentially decaying averages, they calculate a global average overall performance tasks for a fixed utilisation-history window (10 to 50milliseconds) rather than a task-based average over a variabletask-based utilisation-history window.

According to the perspectives-based algorithm of the present techniqueit is necessary to avoid a situation occurring whereby a newnon-interactive CPU bound task utilises the processor for an extensiveperiod without being pre-empted. This could introduce substantiallatency in adaptation of the performance level to the task since theutilisation-history window can only be defined once the task has beenpre-empted at least once. To avoid unwanted performance adaptationlatency an upper threshold is set for the non pre-empted duration overwhich the work estimate is calculated. In particular, if a taskcontinues without being pre-empted for 100 milliseconds, then its workestimate is recalculated by default. The value of 100 milliseconds wasselected by taking into account that a more stringentapplication-history window is ensured for interactive applications viathe dominant hierarchical layer 210, which produces a separateinteractive application performance indicator. It was also consideredthat the only class of user applications likely to be affected by the100 millisecond window threshold are computationally intensive batchjobs such as compilation, which are likely to run for several seconds oreven minutes. In such cases an extra 100 milliseconds (0.1 seconds) ofrun time is unlikely to be significant performance-wise.

FIG. 5 schematically illustrates an implementation of the three-layerhierarchical performance policy stack of FIG. 2. The implementationcomprises a performance indicator policy stack 510 and a policy eventhandler 530, each of which outputs information to a target performancecalculator 540. The target performance calculator 540 serves to collatethe results from four performance-setting algorithms: top levelinteractive algorithm, middle level application-based algorithm and twodifferent lower level algorithms. The four algorithms are capable ofbeing run concurrently. The target performance calculator 540 derives asingle global target performance level from the multiple performanceindicators (in this case four) produced by the policy stack 510. Thepolicy stack 510 together with the policy event handler 530 and thetarget performance calculator 540 provides a flexible framework formultiple performance-setting policies so that policy algorithms of eachlevel of the stack can be replaced or interchanged as desired by theuser. Accordingly the performance policy-stack provides a platform forexperimentation in which user-customised performance-setting policiescan be incorporated.

Each of the multiple performance-setting algorithms is specialised tocope with a different specific category of run-time events. However,since there are four different algorithms in the example embodiment ofFIG. 5, all outputting different performance-indicators, the softwaremust make decisions as to, which of the four performance-indicatorsshould take precedence in setting the global target value. Furthermore,decisions must be made as to the times at which a global targetperformance-level can be validly calculated, given that eachperformance-setting algorithm can run independently and produce outputat different times. It must also be considered how to combine theperformance-indicators in the event that the multipleperformance-setting algorithms all base their decisions on the sameprocessing event, otherwise spurious target updates may occur.

To address these issues the policy stack 510 algorithms are organised ina three-level hierarchy as shown, where policies at higher levels areentitled to override performance level requests derived from lower (lessdominant) levels. Accordingly, the level 2 algorithm can override thelevel 1 algorithm, which can in turn override the two algorithms oflevel 0. Note that each hierarchical level may itself comprise multiplealternative performance-setting algorithms. The differentperformance-setting algorithms are not aware of their positions in thehierarchy and can base their performance decisions on any event in thesystem. When a given algorithm requests a performance level it submits acommand along with its desired performance level to the policy stack510. For each algorithm of the policy stack a data structure comprisinga command 512, 516, 520, 524 and a corresponding performance levelindicator 514, 518, 522 and 526 is stored. The command IGNORE 520 whichapplies to the level 1 algorithm indicates to the target performancecalculator 440 that the associated performance-level indicator should bedisregarded in calculation of the global performance target. The commandSET 512, 516 that has been specified for both of the level 0 algorithmscauses the target performance calculator 540 to set the correspondingperformance level without regard to any performance-level request comingfrom lower in the hierarchy. However the SET command cannot overrideperformance level requests from higher hierarchical levels. In thisembodiment one level 0 algorithm has requested that the performance beset to 55% of peak level whereas another level 0 algorithm has requestedthat the performance be set to 25% of peak level. The target performancecalculator uses an operator to combine these two equal-priorityrequests, in this case preferentially selecting the 55% value as thelevel 0 performance-indicator. At level 2, the command ‘SET IF GREATERTHAN’ has been specified together with a performance indicator of 80%.The ‘SET IF GREATER THAN’ command provides that the target performancecalculator 540 should set the global target performance-level to be 80%provided that this is greater than any of the performance indicatorsfrom lower hierarchical levels. In this case the level 0 performanceindicator is 55% and the level 1 performance indicator is to bedisregarded so that the global target will indeed be set to 80% of peakperformance.

Since the most recently calculated performance level indicators for eachalgorithm are stored in memory by the policy stack 510, the targetperformance calculator 540 can calculate a new global target value atany time without having to invoke each and every performance-settingalgorithm. When a new performance level request is calculated by one ofthe algorithms on the stack, the target performance calculator willevaluate the contents of the command-performance data structures fromthe bottom level up to compute an updated global target performancelevel. Accordingly in the example of FIG. 5, at level 0 the globalprediction is set to 55%, at level 1 it remains at 55% and at level 2the global prediction changes to 80%. Although each of theperformance-setting algorithms can be triggered (by a processing eventin the system) to calculate a new performance level at any time there isa set of common events to which all of the performance-settingalgorithms will tend to respond. These events are monitored and flaggedby the policy event handler 530, which provides policy event informationto the target performance calculator 540. This special category ofevents comprises reset events 532, task switch events 534 andperformance change events 536. The performance change event 536, is anotification that alerts each performance setting algorithm to thecurrent performance level of the processor although it does not usuallyalter the performance requests on the policy stack 510. For this specialcategory of policy events 532, 534, 536, the global target level is notrecomputed each time one of the algorithms issues an updatedperformance-level indicator. Rather, the target performance levelcalculation is co-ordinated so that the calculation is performed onceonly for each event notification after all event handlers of allinterested performance setting algorithms have been invoked.

Device drivers or devices themselves may be provided with an applicationprogram interface (API) that enables an individual device to inform thepolicy stack 510 and/or individual performance setting algorithms of thepolicy stack of any significant change in operating conditions. Thisallows the performance-setting algorithms to trigger recalculation oftarget performance levels thereby promoting rapid adaptation to thechange in operating conditions. For example, a notification could besent by the device to the policy stack 510 when a processor-intensiveCPU-bound task starts up. Such a notification is optional and theperformance-setting algorithms may but need not respond to it onreception.

FIG. 6 schematically illustrates a work-tracking counter 600 accordingto the present technique. The work-tracking counter 600 comprises: anincrement value register 610 having a software control module 620 and ahardware control module 630; an accumulator module 640 comprising awork-count value register and a time-count value register; a time-baseregister 646; a real-time clock 650 and a control register 660. Thework-tracking counter of this example embodiment differs from knowntimestamp counters and CPU cycle counters in that the counter incrementvalues are proportional to the actual work being performed by theprocessor at or close to the time that the count value is incremented.The increment value register 610 comprises a work-done calculator thatestimates the work done by the processor in each counter cycle. The workdone estimates are obtained via the software control module 620 and/orvia the hardware control module 630. The software control module 620implements a simple work-done calculation that correlates the incrementvalue with the current processor speed. If the processor is running at70% of peak performance then the increment value will be 0.7 whereas ifthe processor is running at 40% of peak-performance the increment valuewill be 0.4. When the software control module 620 detects that theprocessor is idle during a counter cycle then the increment value is setto zero. In alternative embodiments of the work-tracking counter a moresophisticated software algorithm is used to calculate a refinedwork-done estimate.

Table 1 lists measurement data that gives a percentage discrepancybetween an expected run-time duration and an actual run-time durationfor both a CPU bound loop and for an MPEG video workload whenconsidering a performance-level transition between two differentprocessor speeds (from a higher to a lower speed in this case). Theresults are based on post-transition runs at three distinct processorperformance levels: 300, 400, and 500 Mhz (as specified in the left-mostcolumn of table). The top row of Table 1 lists the initial performancelevel from which the transition to the corresponding processor speed inthe left-most column was made. On the CPU bound loop, the differencebetween the predicted and actual measurements are indistinguishable fromthe noise, whereas for the MPEG workload, there is about a 6%-7%inaccuracy penalty per 100 Mhz step in processor frequency. The maximuminaccuracy on these workloads is seen to be less than 20% (19.4%),whichis considered to be acceptable for a system with only a few fixableperformance-levels. However as the available range of minimum to maximumprocessor performance levels that are selectable in a system increasesand the range of each performance-level step decreases, it is likelythat a more accurate work-estimator than the processor speed will berequired.

Post- CPU BOUND LOOP MPEG VIDEO WORKLOAD transition 400 500 600 400 500600 speed MHz MHz MHz MHz MHz MHz 300 MHz −0.3% −0.4% −0.3% 7.1% 13.5%19.4% 400 MHz −0.1% 0.0% 6.9% 13.3% 500 MHz 0.1% 6.8%

The more sophisticated algorithm of alternative example embodiments usesa more accurate work-done estimation technique that involves monitoringthe instruction profile (via counters that keep track of significantevents such as memory accesses) and the expected and actual decreaserate of the workload, rather than making the assumption that thework-done is directly proportional to the processor speed. Furtheralternative embodiments use cache hit-rates and memory-systemperformance indicators to refine the work-done estimate. Yet furtheralternative example embodiments use software to monitor the percentageof processing time used in executing a programming application (equatedto useful work-done) relative to the percentage of processing time usedin performing background operating-system tasks.

The hardware control module 630 is capable of estimating work-done evenduring transition periods when the processor is in the process ofswitching between two fixed performance levels. For each processorperformance transition there will be a pause of around 20 microsecondsduring which the processor does not issue any instructions. This pauseis due to the time needed to resynchronise the phase-locked-loops to thenew target processor frequency. Furthermore, before the processorfrequency can be changed, the voltage must be stabilised to anappropriate value for the new target frequency. Accordingly, there is atransition time of up to 1 millisecond, during which it can be assumedthat the processor is running at the old target frequency but energy isbeing consumed at the new target level (since the voltage has been setto the new target level). The frequency may be ramped up in severalstages via intermediate frequency steps to affect the performance-levelchange. During such transition periods when the frequency of theprocessor is changing dynamically the hardware control module 630 isoperable to update the increment value register taking account of thedynamic changes of which the software is unaware. Although this exampleembodiment makes use of both hardware and software control modules 620,630 to calculate the work done, alternative example embodiments may useonly one of these two modules to estimate the work-done.

The accumulator(s) module 640 periodically reads the increment valuefrom the increment value register 610 and adds the increment value to anaccumulated sum stored in the work-count value register. The work-countvalue register increments the work-count value every clock-tick. Theclock-tick is a time signal derived from the real-time clock 650. Tomeasure the work-done during a predetermined time-interval thework-count value stored in the accumulator(s) module 640 is read twice:once at the beginning of the predetermined time interval and once at theend. The difference between these two values provides an indication ofthe work-done during the predetermined time interval.

The real-time clock 650 also controls the rate at which the time-countvalue stored in the register 644 is incremented. This time-count valueregister works on the same time base as the work-count value but is usedto measure time elapsed rather than work done. Having both a timecounter and a work-done counter facilitates performance-settingalgorithms. The time-base register 646 is provided for the purpose ofmulti-platform compatibility and conversion to seconds. It serves tospecify the time base (frequency) of the two counters 642, 644 so thattime can be accurately and consistently be i.e. the accumulated valuestored in the time count value register provides an indication of thetime elapsed in milliseconds. The control register module 660 comprisesa two control registers, one for each counter. A counter can be enabled,disabled or reset via the appropriate control register.

FIG. 7 schematically illustrates an apparatus that is capable ofproviding a number of different fixed performance-levels in dependenceupon workload characteristics. The apparatus comprises a CPU 710, areal-time clock 720, a power supply control module 730 and the incrementvalue register 610 of the work-tracking counter of FIG. 6. The powersupply control module 730 determines which of the fixedperformance-levels the CPU is currently set to run at and selects anappropriate clock frequency for the real-time clock 720. Thepower-supply control module 730 inputs information on the currentprocessor frequency to the increment value register 610. Accordingly thevalue of the increment is proportional to the processor frequency, whichin turn provides an estimate of useful work-done by the processor.

Many of the performance-setting algorithms of the policy stack 510 usethe utilisation history of the processor over a given time interval(window) to estimate the appropriate future target speed of theprocessor. The principal objective of any performance-setting policy isto maximise the busy time of the processor in the period from the startof execution through to the task deadline by reducing the processorfrequency and voltage levels an appropriate target performance level.

To enable the target performance level to be realistically predicted,the intelligent energy manager 120 provides an abstraction for trackingthe actual work done by the processor during a given time interval. Thiswork-done abstraction allows performance changes and idle time to betaken into account regardless of the specific hardware counterimplementations, which can vary between platforms. According to thepresent technique, to obtain a work measurement estimate over a timeinterval, each performance-setting algorithm is allocated a ‘workstructure’ data structure. Each algorithm is set up to call a‘work-start function’ at the beginning of the time interval and a‘work-stop function’ at the end of the given time interval. During thework-done measurement, the contents of the work structure areautomatically updated to specify the proportion of idle time and theproportion of utilised processor time weighted by the respectiveperformance levels of the processor. The information stored in the workstructure is then used to compute the full-speed equivalent work value(Work_(fse)), which is subsequently be used for target performance-levelprediction. This work-done abstraction functionality, which isimplemented in software in the intelligent energy manager 120 providesperformance-level prediction algorithm developers with a convenientinterface to the intelligent energy manager 120. The work-doneabstraction also simplifies porting of the performance-setting system ofthe present technique to different hardware architectures.

One significant difference between alternative hardware platforms is themanner in which time is measured on the platform. In particular, somearchitectures provide a low overhead method of cycle-counting viatimestamp counters whereas other architectures only provide the userwith externally programmable timer interrupts. However even whentimestamp counters are provided they do not necessarily measure the samethings. For example a first category of hardware platforms includes bothcurrent Intel [RTM] Pentium and ARM [RTM] processors. In theseprocessors the timestamp counters count CPU-cycles so that thecount-rate varies in accordance with the speed of the processor and thecounter stops counting when the processor enters into sleep mode. Asecond category of hardware platforms, which includes the Crusoe [RTM]processor, have an implementation of the timestamp counter thatconsistently counts the cycles at the peak rate of the processor andcontinues to increment the count at the peak rate even when theprocessor is in sleep mode. The work-done abstraction facilitatesimplementation of the present target performance-setting technique onboth of these two alternative categories of hardware platform.

The work estimate Work_(fse) as calculated in this embodiment does nottake account of the fact that a given workload running at half of peakperformance does not necessarily take twice as long to run to completionas it would at the full processor speed. One reason for thiscounter-intuitive result is that although the processor core is sloweddown, the memory system is not. As a result, the core to memoryperformance ratio improves in the memory's favour.

Simulations were performed to evaluate the present performance-settingtechnique against a known technique. In particular, the known techniqueis a ‘LongRun’ power manager that is built-into a Transmeta Crusoeprocessor. The Transmeta's Crusoe processor has the LongRun powermanager built into the processor firmware. LongRun is different fromother known power management techniques in that it avoids the need tomodify the operating system in order to effect the power management.LongRun uses the historical utilisation of the processor to guide clockrate selection: it speeds up the processor if utilisation is high anddecreases performance if utilisation is low. Unlike on more conventionalprocessors, the power management policy can be implemented on the Crusoeprocessor relatively easily because the processor already has a hiddensoftware layer that performs dynamic binary translation andoptimisations. The simulations aimed to establish how effectively apolicy such as LongRun that is implemented at such a low level in thesoftware hierarchy can perform. The present technique was run alongsideLongRun on the same processor.

The simulations were performed on a Sony Vaio [RTM] PCG-C1VN notebookcomputer using the Transmeta Crusoe 5600 processor running at a numberof fixed performance levels ranging from 300 Mhz to 600 Mhz in 100 Mhzperformance-level steps. The simulations used a Mandrake 7.2 operatingsystem with a modified version of the Linux 2.4.4-ac18 kernel. Theworkloads used in the comparative evaluation were as follows: PlaympegSDL MPEG player library; Acrobat Reader for rendering PDF files; Emacsfor text editing; Netscape Mail and News 4.7 for news reading; Konqueror1.9.8 for web browsing; and Xwelltris 1.0.0 as a 3D game. The benchmarkused for interactive shell commands was a record of a user performingmiscellaneous shell operations during a span of about 30 minutes. Toavoid possible variability due to the dynamic translation engine of theCrusoe processor, most benchmarks were run at least twice to warm up thedynamic translation cache, simulation data from all but the last run wasdisregarded.

The performance-setting algorithm according to the present technique hasbeen designed so that it is unobtrusive to its host platform is the waytimers are handled. For the purpose of the simulations the presenttechnique provided a sub-millisecond resolution timer, without changingthe way in which the Linux built-in 10 ms resolution timer worked. Thiswas accomplished by piggybacking a timer dispatch routine (which checksfor timer events) onto often executed parts of the kernel, such as thescheduler and system calls.

Since the performance-setting algorithm according to the presenttechnique is designed such that it has hooks to the kernel that allow itto intercept certain system calls to find interactive episodes and it isinvoked on every task switch, it was straight-forward to add a fewinstructions to these hooks to manage timer dispatches. Each hook wasaugmented by implementing a read of the timestamp counter, a comparisonagainst the time stamp of the next timer event and a branch to the timerdispatch routine upon success. In practice it was found that thisstrategy yielded a timer with sub-millisecond accuracy.

Table 2 below details the timer statistics pertaining to thesimulations. The worst-case timer resolution was bounded by the 10millisecond (seems to be inconsistent with Table 2) time quantum of thescheduler. However, since the events that the performance-settingalgorithm according to the present technique is interested in measuringusually occur close to the timer triggers, the achieved resolution wasconsidered to be adequate. It proved to be advantageous that thesoft-timers of the system stopped ticking when the processor was insleep mode since this meant that the timer interrupts did not change thesleep characteristics of the running operating system and programapplications. The timers used had high resolution but low overhead.

These advantageous features of the timers facilitated development of animplementation having both an active mode and a passive mode. In theactive mode the performance-setting algorithm according to the presenttechnique was in control. In the passive mode the built-in LongRun powermanager was in charge of performance although the intelligent energymanager of the present technique acted as an observer of the executionand performance changes.

TABLE 2 Cost of an access to a timestamp  30 to 40 cycles counter Meaninterval between timer checks ~0.1 milliseconds Timer accuracy   ~1millisecond Average timer check and dispatch 100 to 150 cycles duration(including possible execution of an event handler)Monitoring the performance changes caused by LongRun was accomplishedsimilarly to the timer dispatch routine. The intelligent energy manager120 according to the present technique periodically read the performancelevel of the processor through a machine-specific register and comparedthe result to a previous value. If the two values were different, thenthe change was logged in a buffer. The intelligent energy manageraccording to the present technique includes a tracing mechanism thatretains a log of significant events in a kernel buffer. This logincludes performance-level requests from the different policies, taskpre-emptions, task IDs (identifiers), and the performance levels of theprocessor. In performing the simulations it was possible to compareLongRun and the performance-setting algorithm according to the presenttechnique during the same execution run: LongRun was is in controlperformance-setting while the intelligent energy manager 120 of thepresent technique was operable to output the decisions that it wouldhave made on the same workload, had it been in control. This simulationstrategy was used to objectively assess the differences betweenunrepeatable runs of interactive benchmarks between the known LongRuntechnique and the present technique.

In order to assess the overhead of using the measurement andperformance-setting techniques, the performance-setting algorithmaccording to the present technique was instrumented with markers thatkept track of the time spent in the performance-setting algorithm codeat run-time. Although the run-time overhead of the present technique ona Pentium II was found to be around 0.1% to 0.5%, on the TransmetaCrusoe processor the overhead was between 1% and 4%. Furthermeasurements in virtual machines such as ‘VMWare’ and ‘user-mode-linux’(UML) confirmed that the overhead of the performance-setting algorithmsaccording to the present technique can be significantly higher invirtual machines than on traditional processor architectures. Howeverthis overhead could be effectively reduced by algorithm optimisation.

MPEG (Motion Pictures Expert Group) video playback posed a difficultchallenge for all of the tested performance-setting algorithms. Althoughthe performance-setting algorithms typically put a periodic load on thesystem, the performance requirements can vary depending on the MPEGframe-type. As a consequence, if a performance-setting algorithm uses acomparatively long time-window corresponding to past (highly variable)MPEG frame-decoding events to predict future performance requirements,it can miss the execution deadlines for (less-representative) morecomputationally intensive frames. On the other hand, if the algorithmlooks at only a short interval, then it will not converge to a singleperformance value but oscillate rapidly between multiple settings. Sinceeach change in performance-level incurs a transition delay, rapidoscillation between different performance-levels is undesirable. Thesimulation results for LongRun confirm this oscillatory behaviour forthe MPEG benchmark.

The present technique deals with this problem of oscillation for theMPEG workload by relying on the interactive performance-settingalgorithm at the top level of the hierarchy to bound worst-caseresponsiveness. The more conventional interval-based perspectivesalgorithm at the bottom level of the hierarchy is thus able to take alonger-term view of performance-level requirements.

FIG. 8 is a table that details simulation measurement results for the‘plaympeg’ video player(http://www.lokigames.com/development/smpeg.php3) playing a variety ofMPEG videos. Some of the internal variables of the video player havebeen exposed to provide information about how the player is affected asthe result of dynamically changing the processor performance-levelduring execution. These figures are shown in the MPEG decode column ofthe table. In particular, the ‘Ahead’ variable measures how close to thedeadline each frame decoding comes. The closeness to the deadline isexpressed as cumulative seconds during the playback of each video. Formaximum power efficiency, the Ahead variable value should be as close tozero as possible, although the slowest performance level of theprocessor puts a lower limit how much the Ahead value can be reduced. An‘Exactly on time field’ in the right-most column of the table specifiesthe total number of frames that met their deadlines exactly. The moreframes that are exactly on time, the closer the performance-settingalgorithm is to the theoretical optimum. The data in the ExecutionStatistics column of the table of FIG. 8 was collected by theintelligent energy manager 120 monitoring sub-system. To collectinformation about LongRun, the intelligent energy manager 120 was usedin passive mode to gather a trace of performance changes withoutcontrolling the processor performance level. The Idle field specifiesthe fraction of time spent in the idle loop of the kernel (possiblydoing housekeeping chores or just spinning) whereas the Sleep fieldspecifies the fraction of time that the processor actually spends in alow-power sleep mode. It can be seen from the table in FIG. 8 that foreach of these performance measures the present technique performsconsiderably better than LongRun.

FIG. 9 is a table that lists processor performance level statisticscollected during the runs of each workload. The fraction of time at eachperformance level is computed as a proportion of the total non-idle timeduring the run of the workload. The ‘Mean perf’ level column of thetable specifies the average performance levels (as the percentage ofpeak performance) during the execution of each workload. Since, in allcases, the mean performance level for each workload was lower using thepresent technique than for LongRun, the last column specifies the meanperformance reduction achieved with regard to LongRun. The playbackquality for both the LongRun workload and the workload of the presenttechnique was the same i.e. identical frame rates and no dropped frames.

The results show that the present technique is more accurately able topredict the necessary performance level than the known LongRuntechnique. The increased accuracy results in an 11% to 35% reduction ofthe average performance levels of the processor during execution of thebenchmarks. Since the amount of work between runs of a workload shouldstay the same, the lower average performance level implied that reducedidle and sleep times could be expected when the intelligent energymanager of the present technique is enabled. This expectation wasaffirmed by the simulation results. Similarly, the number of frames thatexactly meet their deadlines increases when the intelligent energymanager of the present technique is enabled and the cumulative amount oftime when decode is ahead of its deadline is reduced.

The median performance level (highlighted with bold in each column ofthe table of FIG. 9) also shows significant reductions. Whereas on mostbenchmarks the performance-setting algorithm according to the presenttechnique settles on a single performance level below peak for thegreatest fraction of execution time (>88%), LongRun usually sets theprocessor to run at full-speed. The exception to this general rule isthe ‘Danse De Cable’ workload, where the performance-setting algorithmaccording to the present technique settles on the lowest two performancelevels and oscillates between these two levels. The reason for thisoscillatory behaviour is due to the specific performance levels on theCrusoe processor. The performance-setting algorithm according to thepresent technique would have elected to select a performance level ofonly slightly higher than 300 Mhz so that as the performance-levelprediction fluctuated above and below the 300 MHz value, the targetperformance-level was quantized to the closest two performance levels.The most notable difference in performance between the known LongRuntechnique and the present technique is that LongRun appears to beover-cautious in that it ramps up the performance level very quicklywhen it detects significant amounts of processor activity.

Over all workloads, the average processor performance level with LongRunnever fell below 80%, whilst the performance level set by the presenttechnique fell to as low as 52% for the ‘Red's Nightmare small’benchmark. The algorithm according to the present technique is moreaggressive than LongRun but responds quickly when the quality of serviceappears to have been compromised. Since LongRun does not have anyinformation about the interactive performance, it is forced to actconservatively on a shorter time frame and the simulation results showthat this leads to inefficiencies.

FIG. 10 comprises two graphs of results for playback of two differentMPEG movies entitled ‘Legendary’ (FIG. 10A) and ‘Danse de Cable’ (FIG.10B). Each graph illustrates the fraction of time spent at each of fourprocessor performance levels (300, 400, 500, and 600 MHz) for bothLongRun and the present technique. Although the playback quality of foreach run was identical, it can be seen from the graphs that use of thealgorithm according to the present technique meant that the processorspent significantly longer at below peak performance than it did whenthe LongRun technique specified the performance level. The results forplayback of the ‘Legendary’ movie plotted in FIG. 10A show that thealgorithm according to the present technique settles on a performancelevel of 500 MHz. The results for the ‘Danse de Cable’ movie shown inFIG. 10B reveal that using the algorithm according to the presenttechnique, the processor switched between two performance-levels i.e.300 MHz and 400 MHz. By way of contrast, for both of these movies theLongRun performance setting algorithm chose the peak processor speed of600 MHz for a dominant portion of the execution time.

FIG. 11 provides qualitative insight into the characteristics of the twodifferent performance-setting policies. LongRun keeps switching theperformance level up and down in fast succession, while the processorperformance-level of the system when controlled according to the presenttechnique stays close to a target performance level. The two graphs ofFIG. 11A (top row) show the performance levels of the processor during abenchmark run with LongRun enabled. FIGS. 11B and 11C (middle and bottomrows) show performance-level results for the same benchmark but with thealgorithm of the present technique enabled. FIG. 11B shows the actualperformance levels during execution, while FIG. 11C reflects theperformance level that the performance-setting algorithm according tothe present technique would request on a processor that could run atarbitrary performance levels (given the same max. performance). Notethat in some cases, the desired performance levels calculated byalgorithm according to the present technique the are actually below theminimum achievable performance-level on the processor.

Now consider simulation results for comparison of the two techniques oninteractive workloads. Due to the difficulty in making interactivebenchmark runs repeatable, interactive workloads are significantlyharder to evaluate than the multimedia benchmarks. To circumvent thisproblem, empirical measurements were combined with a simple simulationtechnique. More specifically, the interactive benchmarks were run underthe control of the native LongRun power manager and the intelligentenergy manager 120 according to the present technique was only engagedin passive mode, so that it merely recorded the performance-settingdecisions that it would have made but did not actually change theperformance levels of the processor.

FIG. 12 shows the performance data that was collected during asimulation run for assessment of interactive workloads. FIG. 12A is agraph of percentage performance level against time (in seconds) for theLongRun technique and in this case the plotted results correspond to theactual performance levels of the processor during the measurement. FIG.12B is a plot of the quantized performance levels whereas FIG. 12C is aplot of the raw performance levels as a function of time that theperformance-setting algorithm of the present technique would have set,had it been in control of the processor. Note that if the algorithm ofthe present technique had in fact been in control, itsperformance-setting decisions would have had a different run-time impactfrom those made by LongRun. For this reason the time axes on the graphsof FIGS. 12B and 12C should be regarded as approximations.

To get around the time-skew problem in the statistics, the passiveperformance-level traces of the simulations according to the presenttechnique were post-processed to assess the impact of the increasedexecution times that would have resulted from the use of the presenttechnique instead of LongRun. Rather than looking at the entireperformance-level trace, only on the interactive episodes were focussedon. The interactive performance-setting algorithm of the presenttechnique, it includes functionality for finding durations of executionthat have a direct impact on the user. This technique gives validreadings regardless of which algorithm is in control and was thus usedto focus our measurements. Once the execution range for an interactiveepisode had been isolated, the full-speed equivalent work done duringthe episode was computed for both LongRun and the present technique.Since during the measurement LongRun is in control of the CPU speed andit runs faster than it would do if the resent technique were in control,the episode duration of results corresponding to the present techniquemust be lengthened. First, the remaining work is computed for thepresent technique according to the following formula:Work_(Present technique Remaining)=Work_(LongRun)−Work_(Present technique)

Next, the algorithm computed to what extent the length of theinteractive episode needed to be stretched—assuming that the algorithmof the present technique continued to run at its predicted speed untilit reached the panic threshold, at ran at full-speed after that. Thestatistics were adjusted accordingly. It was found that the resultsusing this technique were close to what we observed on similar workloads(same benchmark but with a slightly different interactive load) runningwith the algorithm according to the present technique in active controlof the processor. However, when the algorithm according to the presenttechnique was actually in control, the number of performance-settingdecisions was reduced and the performance-levels were more accurate.

FIG. 13 shows the statistics gathered using the above-describedtime-skew correction technique. Each of the six graphs in the figuregraph comprises two stacked columns. The left-hand column on each graphrelates to LongRun whereas the right-hand column relates to the presenttechnique. Each column is stacked so as to represent the fraction oftime spent in interactive episodes at each of the four performancelevels supported in the computer. These performance levels—from bottomup—are from 300 Mhz to 600 Mhz at 100 Mhz increments. Even from a highlevel, it is apparent that the algorithm according to the presenttechnique spends more time at lower performance levels than LongRundoes. On some benchmarks such as Emacs, there is hardly ever a need togo fast and the interactive deadlines are met while the machine stays atits lowest possible performance level. At the other end of the spectrumis the Acrobat Reader benchmark, which exhibits bimodal behaviour: theprocessor either runs at its peak level or at its minimum. Even on thisbenchmark many of the interactive episodes can complete in time at theminimum performance level of the processor. However, when it comes torendering the pages, the peak performance level of the processor is notsufficient to complete its deadlines within the user perceptionthreshold. Thus, upon encountering a sufficiently long interactiveepisode, the algorithm according to the present technique switches theprocessor performance-level to its peak. By way of contrast, during therun of the Konqueror benchmark, the algorithm according to the presenttechnique can take advantage of all four available performance levels ofthe processor. This can be compared with the LongRun strategy, whichcauses the processor to spend most of its time at the peak level.

Overall, the simulation results detailed above with reference to FIGS. 8to 13, have shown how two performance-setting policies implemented atdifferent levels in the software hierarchy behave on a variety ofmultimedia and interactive workloads. It was found that the TransmetaLongRun power manager, which is implemented in the processor's firmware,makes more conservative choices than the algorithm according to thepresent technique, which is implemented in the kernel of the operatingsystem. On a set of multi-media benchmarks an 11% to 35% averageperformance level reduction was achieved by the algorithm according tothe present technique over that achieved using the known LongRuntechnique.

Since the performance-setting algorithm according to the presenttechnique is implemented higher in the software stack than LongRun it isable to make decisions based on a richer set of run-time information,which in turn translates into increased accuracy.

Although the firmware approach of LongRun was shown to be less accuratethan an algorithm implemented in the kernel, it does not diminish itsusefulness. LongRun has the crucial advantage of being operating systemagnostic. It is recognised that the gap between low and high levelimplementations could be bridged by to providing a baselineperformance-setting algorithm such as LongRun in firmware and exposingan interface to the operating system for the purpose of (optionally)refining processor performance-setting decisions. The hierarchy ofperformance-setting algorithms according to the present techniqueprovides a mechanism to support such design. The bottom-mostperformance-setting policy on the stack could actually be implemented inthe firmware of the processor.

Although illustrative embodiments of the invention have been describedin detail herein with reference to the accompanying drawings, it is tobe understood that the invention is not limited to those preciseembodiments, and that various changes and modifications can be effectedtherein by one skilled in the art without departing from the scope andspirit of the invention as defined by the appended claims.

1. Apparatus for processing data, said apparatus being operable toperform processing work at a variable rate of work and comprising: aperformance counter operable to add a work increment value to anaccumulated work done value to accumulate a work done value indicativeof an amount of processing work performed by said apparatus; and a clocksignal generator operable to generate a clock signal to drive processingoperations of said apparatus, said clock signal having a variablefrequency, wherein said word increment value is variable so as torepresent said variable rate of work and said work in increment value isdependent upon a clock signal frequency value at or close to a time thatthe accumulated work done value is incremented.
 2. Apparatus as claimedin claim 1, comprising an increment value adjusting circuit operable toadjust said work increment value in dependence upon said clock signalfrequency.
 3. Apparatus as claimed in claim 2, wherein said workincrement value variable non-linearly with said clock signal frequency.4. Apparatus as claimed in claim 1, comprising a variable voltage powersupply operable to supply electrical power to said apparatus at aplurality of different supply voltages, said clock signal generatorbeing operable to generate higher frequency clock signals at highersupply voltages.
 5. Apparatus as claimed in claim 1, wherein said workincrement value is programmable under software control.
 6. Apparatus asclaimed in claim 1, wherein said work increment value is varied with aread-modify-write operation.
 7. A method of measuring processing workperformed by an apparatus for processing data at a variable rate ofwork, said method comprising the steps of: adding a work increment valueto an accumulated work done value with a performance counter toaccumulate a work done value indicative of an amount of processing workperformed by said apparatus; generating a variable frequency clocksignal to drive processing operations of the apparatus, and varying saidwork increment value dependent upon a frequency value of said clocksignal so as to represent said variable rate of work where saidfrequency value is a frequency value of said clock signal at or as closeto a time that the accumulated work done value is incremented.
 8. Amethod as claimed in claim 7, comprising adjusting said work incrementvalue in dependence upon said clock signal frequency.
 9. A method asclaimed in claim 8, wherein said work increment value variablenon-linearly with said clock signal frequency.
 10. A method as claimedin claim 7, comprising supplying electrical power to said apparatus at aplurality of different supply voltages and generating higher frequencyclock signals at higher supply voltages.
 11. A method as claimed inclaim 7, wherein said work increment value is programmable undersoftware control.
 12. A method as claimed in claim 7, wherein said workincrement value is varied with a read-modify-write operation.